package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
	_ "shangyuapi/data_source"
	"shangyuapi/middle_ware"
	all_router "shangyuapi/router"
	"shangyuapi/tool"
)

func main() {

	cfg, err := tool.ParseConfig("./config/app.json")
	if err != nil {
		panic(err.Error())
	}
	router := gin.Default()
	router.StaticFS("/upload", http.Dir("./upload"))
	//使用全局中间件 实现跨域请求
	router.Use(middle_ware.CrosMiddleWare)
	//注册路由组 - router-router.go
	all_router.InitRouter(router)
	router.Run(cfg.Server.Host + ":" + cfg.Server.Port)
}
